package cn.com.bluemoon.daps.model.core.file;

import cn.com.bluemoon.daps.common.domain.ResultBean;
import cn.com.bluemoon.daps.model.entity.DapDataModel;
import cn.com.bluemoon.daps.model.entity.DapDataModelTablePartition;

/**
 * 分区抽象类
 *
 * @author Jarod.Kong
 * @date 2021/2/7 16:17
 */
public abstract class PartitionData extends IMetaData<DapDataModelTablePartition>
        implements IConvertToModel<DapDataModelTablePartition> {

    // 分区字段
    public abstract String getPartitionFieldName();

    // 字段类型
    public abstract Integer getPartitionFieldType();

    public abstract String getPartitionComment();

    @Override
    public ResultBean<DapDataModelTablePartition> convertToModel(DapDataModel model) {
        DapDataModelTablePartition partition = new DapDataModelTablePartition();
        partition.setPartitionFieldType(getPartitionFieldType());
        partition.setPartitionFieldName(getPartitionFieldName());
        partition.setName(getPartitionComment());
        return ResultBean.ok(partition);
    }

    /**
     * 来自数据库的模型
     *
     * @param model 来自数据库的模型
     */
    @Override
    public PartitionData copyDbProperties0(DapDataModelTablePartition model) {
        return this;
    }

    @Override
    public String sheetName() {
        return "分区";
    }

    @Override
    public Integer sheetNo() {
        return 2;
    }
}
